#include"comm.h"
#include<string.h>

int main()
{
  /*不需要创建fifo，只需获取即可*/
  int fd = open(MY_FIFO, O_WRONLY);
  if(fd < 0)
  {
    perror("open");
    return 1;
  }

  //业务逻辑
  while(1)
  {
    char buffer[64] = {0};
    /*先把数据从标准输入拿到client进程内部*/
    printf("Plz enter message:");
    fflush(stdout);
    ssize_t s = read(0, buffer, sizeof(buffer)-1);
    if(s > 0)
    {
      //拿到了待发送数据
      buffer[s-1]=0;
      printf("%s\n",buffer);
      //发送数据
      write(fd, buffer, strlen(buffer));
    }
  }
  close(fd);
  return 0;
}
